//
//  CallCenterManager.m
//  Financial
//
//  Created by SuperChao.liang on 2016/11/28.
//  Copyright © 2016年 ZYT.com. All rights reserved.
//

#import "CallCenterManager.h"
#import "CallCenterManager+Layout.h"

// 小球宽高
const CGFloat toolBallWidth = 50;
const CGFloat toolBallHeight = 50;

@implementation CallCenterManager

+ (instancetype)sharedInstance
{
    static CallCenterManager *sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[CallCenterManager alloc] init];
    });
    return sharedInstance;
}

- (id)init
{
    self = [super init];
    if (self) {
        [self initTooleBar];
    }
    return self;
}

#pragma mark - action
+ (void)show
{
    CallCenterManager *toolBall = [CallCenterManager sharedInstance];
    
    UIWindow *delgtWindow = [[[UIApplication sharedApplication] delegate] window];
    NSAssert(delgtWindow.rootViewController != nil, @"显示ToolBall小球请在mainWindow设置过rootViewController之后再进行!!!");
    
    if (delgtWindow.rootViewController != toolBall.window.rootViewController)
    {
        toolBall.window.rootViewController = delgtWindow.rootViewController;
    }
    
    [toolBall.window makeKeyAndVisible];
    toolBall.window.hidden = NO;
}

+ (void)hide
{
    CallCenterManager *toolBall = [CallCenterManager sharedInstance];
    if(toolBall && !toolBall.window.hidden)
    {
        toolBall.window.hidden = YES;
    }
}
@end
